package com.gitee.payment;


import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@EnableEurekaClient
@EnableDiscoveryClient
@Slf4j
@EnableConfigurationProperties({LiquibaseProperties.class})
public class PaymentApplication {

	public static void main(String[] args) throws UnknownHostException {
		SpringApplication app = new SpringApplication(PaymentApplication.class);

		Environment env = app.run(args).getEnvironment();
		String protocol = "http";

		log.info("\n----------------------------------------------------------\n\t" +
						"Application '{}' is running! Access URLs:\n\t" +
						"Local: \t\t{}://localhost:{}\n\t" +
						"External: \t{}://{}:{}\n\t" +
						"ApiDocs: \t{}\n" +
						"ContextPath: \t{}\n----------------------------------------------------------",
				env.getProperty("spring.application.name"),
				protocol,
				env.getProperty("server.port"),
				protocol,
				InetAddress.getLocalHost().getHostAddress(),
				env.getProperty("server.port"),
				env.getProperty("application.doc"),
				env.getProperty("server.servlet.context-path"));
	}

}
